package com.mc.algorithm;

public class EqualIndex {
	public static void main(String[] args){
		
		int[] a = {-3,-1,1,3,5};
		int res = bs(a,0,a.length-1);
		System.out.println(res);
	}
	public static int bs(int[] a,int low,int high){
		while(low<=high){
			int mid = low+(high-low)/2;
			if(a[mid]==mid)
				return a[mid];
			else if(a[mid]<mid)
				low = mid+1;
			else
				high = mid-1;
		}
		return -1;
	}
}
